package priorityqueue;

import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;

class Imp implements Comparator<Integer>{

    @Override
    public int compare(Integer o1, Integer o2) {
        return o2.compareTo(o1);
//        return (o1>o2)?-1:(o1==o2)?0:1;
    }
}
public class Test {
    public static void main1(String[] args) {
        Imp imp = new Imp();
        PriorityQueue<Integer> pq = new PriorityQueue<>(imp);
        pq.offer(1);
        pq.offer(5);
        pq.offer(10);
        System.out.println(pq.peek());
    }
    public static void main(String[] args) {
        TestHeap heap = new TestHeap();
        int[] array = {27,15,19,18,28,34,65,49,25,37};
        heap.initElem(array);
        heap.createHeap();
        System.out.println(Arrays.toString(heap.elem));
        heap.push(80);
        System.out.println(Arrays.toString(heap.elem));
        heap.pop();
        System.out.println(Arrays.toString(heap.elem));
        //堆排序
        heap.heapSort();
        System.out.println(Arrays.toString(heap.elem));
    }
}
